fix(ui): 修复“真实加载/菜单总耗时”长期显示 0ms 的问题#14
Merged
adminLAla merged 2 commits intoHaerbin23456:devfrom Mar 15, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
本 PR 旨在修复 Dashboard 中“真实加载/菜单总耗时”长期显示为 0ms(或被占位值误导)的问题,通过改为基于扫描结果动态汇总计算,并在扫描流程中更稳定地刷新统计。
Changes:
- 扫描开始时将“真实加载”状态设为“测量中”,并在系统扫描结束后强制刷新汇总统计
- 移除文件扫描后触发的 Real Benchmark 跑分逻辑,改由
UpdateStats()基于WallClockTime/TotalTime动态计算真实加载 - 将占位
RunRealShellBenchmark返回值从0调整为-1,避免 UI 将其当作有效耗时
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| ContextMenuProfiler.UI/ViewModels/DashboardViewModel.cs | 扫描流程中刷新“真实加载”状态与汇总逻辑,真实加载改为按结果动态计算 |
| ContextMenuProfiler.UI/Core/BenchmarkService.cs | 调整占位 Real Benchmark API 的返回值,避免 0ms 误导展示 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
472
to
482
| if (results.Count > 0) | ||
| { | ||
| // Use InsertSorted logic for consistency and performance | ||
| foreach (var res in results.OrderByDescending(r => r.TotalTime)) | ||
| { | ||
| InsertSorted(res); | ||
| } | ||
| UpdateStats(); | ||
| StatusText = string.Format(LocalizationService.Instance["Dashboard.Status.ScanComplete"], results.Count); | ||
| NotificationService.Instance.ShowSuccess(LocalizationService.Instance["Dashboard.Notify.ScanComplete.Title"], string.Format(LocalizationService.Instance["Dashboard.Notify.ScanCompleteForFile.Message"], results.Count, System.IO.Path.GetFileName(filePath))); | ||
| } |
Comment on lines
+707
to
+711
| // "Real load" uses wall-clock IPC time when available; fall back to measured COM stage total. | ||
| long realLoadMs = Results | ||
| .Where(r => r.IsEnabled) | ||
| .Sum(r => r.WallClockTime > 0 ? r.WallClockTime : Math.Max(0, r.TotalTime)); | ||
| RealLoadTime = realLoadMs > 0 ? $"{realLoadMs} ms" : "N/A"; |
| @@ -491,7 +491,7 @@ public List<BenchmarkResult> RunBenchmark(string targetPath) | |||
| return RunSystemBenchmark(ScanMode.Targeted); // Simplified for now | |||
| } | |||
|
|
|||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 Issue
变更摘要
1.修复真实加载统计来源,将“真实加载”改为基于当前扫描结果动态计算
2.改善扫描过程中的真实加载状态显示,系统扫描与文件扫描开始时都设置为“测量中”,避免旧值误导。
3.系统扫描结束后强制刷新统计,确保在进度回调为空或边界情况下,汇总指标仍可被刷新。
4.防止占位接口再次误导 UI,将占位接口返回值从 0 改为 -1,避免误被当作有效耗时。
主要改动
验证
截图/日志(如适用)
风险与兼容性